home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / GAS211S2.ZIP / src / gas-211 / include / coff / sym.h < prev    next >
C/C++ Source or Header  |  1993-05-30  |  16KB  |  469 lines

  1. /* Declarations of internal format of MIPS ECOFF symbols.
  2.    Originally contributed by MIPS Computer Systems and Third Eye Software.
  3.    Changes contributed by Cygnus Support are in the public domain.  */
  4.  
  5. /*
  6.  * |-----------------------------------------------------------|
  7.  * | Copyright (c) 1992, 1991, 1990 MIPS Computer Systems, Inc.|
  8.  * | MIPS Computer Systems, Inc. grants reproduction and use   |
  9.  * | rights to all parties, PROVIDED that this comment is      |
  10.  * | maintained in the copy.                                   |
  11.  * |-----------------------------------------------------------|
  12.  */
  13. /* $Header: /rel/cvsfiles/devo/include/coff/sym.h,v 1.3 1992/04/14 22:21:15 gnu Exp $ */
  14. #ifndef _SYM_H
  15. #define _SYM_H
  16.  
  17. /* (C) Copyright 1984 by Third Eye Software, Inc.
  18.  *
  19.  * Third Eye Software, Inc. grants reproduction and use rights to
  20.  * all parties, PROVIDED that this comment is maintained in the copy.
  21.  *
  22.  * Third Eye makes no claims about the applicability of this
  23.  * symbol table to a particular use.
  24.  */
  25.  
  26. /* 
  27.  * This file contains the definition of the Third Eye Symbol Table.
  28.  *
  29.  * Symbols are assumed to be in 'encounter order' - i.e. the order that
  30.  * the things they represent were encountered by the compiler/assembler/loader.
  31.  * EXCEPT for globals!    These are assumed to be bunched together,
  32.  * probably right after the last 'normal' symbol.  Globals ARE sorted
  33.  * in ascending order.
  34.  *
  35.  * -----------------------------------------------------------------------
  36.  * A brief word about Third Eye naming/use conventions:
  37.  *
  38.  * All arrays and index's are 0 based.
  39.  * All "ifooMax" values are the highest legal value PLUS ONE. This makes
  40.  * them good for allocating arrays, etc. All checks are "ifoo < ifooMax".
  41.  *
  42.  * "isym"    Index into the SYMbol table.
  43.  * "ipd"    Index into the Procedure Descriptor array.
  44.  * "ifd"    Index into the File Descriptor array.
  45.  * "iss"    Index into String Space.
  46.  * "cb"        Count of Bytes.
  47.  * "rgPd"    array whose domain is "0..ipdMax-1" and RanGe is PDR.
  48.  * "rgFd"    array whose domain is "0..ifdMax-1" and RanGe is FDR.
  49.  */
  50.  
  51.  
  52. /* 
  53.  * Symbolic Header (HDR) structure.
  54.  * As long as all the pointers are set correctly,
  55.  * we don't care WHAT order the various sections come out in!
  56.  *
  57.  * A file produced solely for the use of CDB will probably NOT have
  58.  * any instructions or data areas in it, as these are available
  59.  * in the original.
  60.  */
  61.  
  62. typedef struct {
  63.     short    magic;        /* to verify validity of the table */
  64.     short    vstamp;        /* version stamp */
  65.     long    ilineMax;    /* number of line number entries */
  66.     long    cbLine;        /* number of bytes for line number entries */
  67.     long    cbLineOffset;    /* offset to start of line number entries*/
  68.     long    idnMax;        /* max index into dense number table */
  69.     long    cbDnOffset;    /* offset to start dense number table */
  70.     long    ipdMax;        /* number of procedures */
  71.     long    cbPdOffset;    /* offset to procedure descriptor table */
  72.     long    isymMax;    /* number of local symbols */
  73.     long    cbSymOffset;    /* offset to start of local symbols*/
  74.     long    ioptMax;    /* max index into optimization symbol entries */
  75.     long    cbOptOffset;    /* offset to optimization symbol entries */
  76.     long    iauxMax;    /* number of auxillary symbol entries */
  77.     long    cbAuxOffset;    /* offset to start of auxillary symbol entries*/
  78.     long    issMax;        /* max index into local strings */
  79.     long    cbSsOffset;    /* offset to start of local strings */
  80.     long    issExtMax;    /* max index into external strings */
  81.     long    cbSsExtOffset;    /* offset to start of external strings */
  82.     long    ifdMax;        /* number of file descriptor entries */
  83.     long    cbFdOffset;    /* offset to file descriptor table */
  84.     long    crfd;        /* number of relative file descriptor entries */
  85.     long    cbRfdOffset;    /* offset to relative file descriptor table */
  86.     long    iextMax;    /* max index into external symbols */
  87.     long    cbExtOffset;    /* offset to start of external symbol entries*/
  88.     /* If you add machine dependent fields, add them here */
  89.     } HDRR, *pHDRR; 
  90. #define cbHDRR sizeof(HDRR)
  91. #define hdrNil ((pHDRR)0)
  92.  
  93. /*
  94.  * The FDR and PDR structures speed mapping of address <-> name.
  95.  * They are sorted in ascending memory order and are kept in
  96.  * memory by CDB at runtime.
  97.  */
  98.  
  99. /* 
  100.  * File Descriptor
  101.  *
  102.  * There is one of these for EVERY FILE, whether compiled with
  103.  * full debugging symbols or not.  The name of a file should be
  104.  * the path name given to the compiler.     This allows the user
  105.  * to simply specify the names of the directories where the COMPILES
  106.  * were done, and we will be able to find their files.
  107.  * A field whose comment starts with "R - " indicates that it will be
  108.  * setup at runtime.
  109.  */
  110. typedef struct fdr {
  111.     unsigned long    adr;    /* memory address of beginning of file */
  112.     long    rss;        /* file name (of source, if known) */
  113.     long    issBase;    /* file's string space */
  114.     long    cbSs;        /* number of bytes in the ss */
  115.     long    isymBase;    /* beginning of symbols */
  116.     long    csym;        /* count file's of symbols */
  117.     long    ilineBase;    /* file's line symbols */
  118.     long    cline;        /* count of file's line symbols */
  119.     long    ioptBase;    /* file's optimization entries */
  120.     long    copt;        /* count of file's optimization entries */
  121.     unsigned short ipdFirst;/* start of procedures for this file */
  122.     short    cpd;        /* count of procedures for this file */
  123.     long    iauxBase;    /* file's auxiliary entries */
  124.     long    caux;        /* count of file's auxiliary entries */
  125.     long    rfdBase;    /* index into the file indirect table */
  126.     long    crfd;        /* count file indirect entries */
  127.     unsigned lang: 5;    /* language for this file */
  128.     unsigned fMerge : 1;    /* whether this file can be merged */
  129.     unsigned fReadin : 1;    /* true if it was read in (not just created) */
  130.     unsigned fBigendian : 1;/* if set, was compiled on big endian machine */
  131.                 /*    aux's will be in compile host's sex */
  132.     unsigned glevel : 2;    /* level this file was compiled with */
  133.     unsigned reserved : 22;  /* reserved for future use */
  134.     long    cbLineOffset;    /* byte offset from header for this file ln's */
  135.     long    cbLine;        /* size of lines for this file */
  136.     } FDR, *pFDR;
  137. #define cbFDR sizeof(FDR)
  138. #define fdNil ((pFDR)0)
  139. #define ifdNil -1
  140. #define ifdTemp 0
  141. #define ilnNil -1
  142.  
  143.  
  144. /* 
  145.  * Procedure Descriptor
  146.  *
  147.  * There is one of these for EVERY TEXT LABEL.
  148.  * If a procedure is in a file with full symbols, then isym
  149.  * will point to the PROC symbols, else it will point to the
  150.  * global symbol for the label.
  151.  */
  152.  
  153. typedef struct pdr {
  154.     unsigned long    adr;    /* memory address of start of procedure */
  155.     long    isym;        /* start of local symbol entries */
  156.     long    iline;        /* start of line number entries*/
  157.     long    regmask;    /* save register mask */
  158.     long    regoffset;    /* save register offset */
  159.     long    iopt;        /* start of optimization symbol entries*/
  160.     long    fregmask;    /* save floating point register mask */
  161.     long    fregoffset;    /* save floating point register offset */
  162.     long    frameoffset;    /* frame size */
  163.     short    framereg;    /* frame pointer register */
  164.     short    pcreg;        /* offset or reg of return pc */
  165.     long    lnLow;        /* lowest line in the procedure */
  166.     long    lnHigh;        /* highest line in the procedure */
  167.     long    cbLineOffset;    /* byte offset for this procedure from the fd base */
  168.     } PDR, *pPDR;
  169. #define cbPDR sizeof(PDR)
  170. #define pdNil ((pPDR) 0)
  171. #define ipdNil    -1
  172.  
  173. /*
  174.  * The structure of the runtime procedure descriptor created by the loader
  175.  * for use by the static exception system.
  176.  */
  177. typedef struct runtime_pdr {
  178.     unsigned long    adr;    /* memory address of start of procedure */
  179.     long    regmask;    /* save register mask */
  180.     long    regoffset;    /* save register offset */
  181.     long    fregmask;    /* save floating point register mask */
  182.     long    fregoffset;    /* save floating point register offset */
  183.     long    frameoffset;    /* frame size */
  184.     short    framereg;    /* frame pointer register */
  185.     short    pcreg;        /* offset or reg of return pc */
  186.     long    irpss;        /* index into the runtime string table */
  187.     long    reserved;
  188.     struct exception_info *exception_info;/* pointer to exception array */
  189. } RPDR, *pRPDR;
  190. #define cbRPDR sizeof(RPDR)
  191. #define rpdNil ((pRPDR) 0)
  192.  
  193. /*
  194.  * Line Numbers
  195.  *
  196.  * Line Numbers are segregated from the normal symbols because they
  197.  * are [1] smaller , [2] are of no interest to your
  198.  * average loader, and [3] are never needed in the middle of normal
  199.  * scanning and therefore slow things down.
  200.  *
  201.  * By definition, the first LINER for any given procedure will have
  202.  * the first line of a procedure and represent the first address.
  203.  */
  204.  
  205. typedef    long LINER, *pLINER;
  206. #define lineNil ((pLINER)0)
  207. #define cbLINER sizeof(LINER)
  208. #define ilineNil    -1
  209.  
  210.  
  211.  
  212. /*
  213.  * The Symbol Structure        (GFW, to those who Know!)
  214.  */
  215.  
  216. typedef struct {
  217.     long    iss;        /* index into String Space of name */
  218.     long    value;        /* value of symbol */
  219.     unsigned st : 6;    /* symbol type */
  220.     unsigned sc  : 5;    /* storage class - text, data, etc */
  221.     unsigned reserved : 1;    /* reserved */
  222.     unsigned index : 20;    /* index into sym/aux table */
  223.     } SYMR, *pSYMR;
  224. #define symNil ((pSYMR)0)
  225. #define cbSYMR sizeof(SYMR)
  226. #define isymNil -1
  227. #define indexNil 0xfffff
  228. #define issNil -1
  229. #define issNull 0
  230.  
  231.  
  232. /* The following converts a memory resident string to an iss.
  233.  * This hack is recognized in SbFIss, in sym.c of the debugger.
  234.  */
  235. #define IssFSb(sb) (0x80000000 | ((unsigned long)(sb)))
  236.  
  237. /* E X T E R N A L   S Y M B O L  R E C O R D
  238.  *
  239.  *    Same as the SYMR except it contains file context to determine where
  240.  *    the index is.
  241.  */
  242. typedef struct {
  243.     unsigned jmptbl:1;    /* symbol is a jump table entry for shlibs */
  244.     unsigned cobol_main:1;    /* symbol is a cobol main procedure */
  245.     unsigned weakext:1;    /* symbol is weak external */
  246.     unsigned reserved:13;    /* reserved for future use */
  247.     short    ifd;        /* where the iss and index fields point into */
  248.     SYMR    asym;        /* symbol for the external */
  249.     } EXTR, *pEXTR;
  250. #define extNil ((pEXTR)0)
  251. #define cbEXTR sizeof(EXTR)
  252.  
  253.  
  254. /* A U X I L L A R Y   T Y P E     I N F O R M A T I O N */
  255.  
  256. /*
  257.  * Type Information Record
  258.  */
  259. typedef struct {
  260.     unsigned fBitfield : 1; /* set if bit width is specified */
  261.     unsigned continued : 1; /* indicates additional TQ info in next AUX */
  262.     unsigned bt  : 6;    /* basic type */
  263.     unsigned tq4 : 4;
  264.     unsigned tq5 : 4;
  265.     /* ---- 16 bit boundary ---- */
  266.     unsigned tq0 : 4;
  267.     unsigned tq1 : 4;    /* 6 type qualifiers - tqPtr, etc. */
  268.     unsigned tq2 : 4;
  269.     unsigned tq3 : 4;
  270.     } TIR, *pTIR;
  271. #define cbTIR sizeof(TIR)
  272. #define tiNil ((pTIR)0)
  273. #define itqMax 6
  274.  
  275. /*
  276.  * Relative symbol record
  277.  *
  278.  * If the rfd field is 4095, the index field indexes into the global symbol
  279.  *    table.
  280.  */
  281.  
  282. typedef struct {
  283.     unsigned    rfd : 12;    /* index into the file indirect table */
  284.     unsigned    index : 20; /* index int sym/aux/iss tables */
  285.     } RNDXR, *pRNDXR;
  286. #define cbRNDXR sizeof(RNDXR)
  287. #define rndxNil ((pRNDXR)0)
  288.  
  289. /* dense numbers or sometimes called block numbers are stored in this type,
  290.  *    a rfd of 0xffffffff is an index into the global table.
  291.  */
  292. typedef struct {
  293.     unsigned long    rfd;    /* index into the file table */
  294.     unsigned long    index;     /* index int sym/aux/iss tables */
  295.     } DNR, *pDNR;
  296. #define cbDNR sizeof(DNR)
  297. #define dnNil ((pDNR)0)
  298.  
  299.  
  300.  
  301. /*
  302.  * Auxillary information occurs only if needed.
  303.  * It ALWAYS occurs in this order when present.
  304.  
  305.         isymMac        used by stProc only
  306.         TIR            type info
  307.         TIR            additional TQ info (if first TIR was not enough)
  308.         rndx        if (bt == btStruct,btUnion,btEnum,btSet,btRange,
  309.                     btTypedef):
  310.                     rsym.index == iaux for btSet or btRange
  311.                     else rsym.index == isym
  312.         dimLow        btRange, btSet
  313.         dimMac        btRange, btSet
  314.         rndx0        As many as there are tq arrays
  315.         dimLow0
  316.         dimHigh0
  317.         ...
  318.         rndxMax-1
  319.         dimLowMax-1
  320.         dimHighMax-1
  321.         width in bits    if (bit field), width in bits.
  322.  */
  323. #define cAuxMax (6 + (idimMax*3))
  324.  
  325. /* a union of all possible info in the AUX universe */
  326. typedef union {
  327.     TIR    ti;        /* type information record */
  328.     RNDXR    rndx;        /* relative index into symbol table */
  329.     long    dnLow;        /* low dimension */
  330.     long    dnHigh;        /* high dimension */
  331.     long    isym;        /* symbol table index (end of proc) */
  332.     long    iss;        /* index into string space (not used) */
  333.     long    width;        /* width for non-default sized struc fields */
  334.     long    count;        /* count of ranges for variant arm */
  335.     } AUXU, *pAUXU;
  336. #define cbAUXU sizeof(AUXU)
  337. #define auxNil ((pAUXU)0)
  338. #define iauxNil -1
  339.  
  340.  
  341. /*
  342.  * Optimization symbols
  343.  *
  344.  * Optimization symbols contain some overlap information with the normal
  345.  * symbol table. In particular, the proc information
  346.  * is somewhat redundant but necessary to easily find the other information
  347.  * present. 
  348.  *
  349.  * All of the offsets are relative to the beginning of the last otProc
  350.  */
  351.  
  352. typedef struct {
  353.     unsigned ot: 8;        /* optimization type */
  354.     unsigned value: 24;    /* address where we are moving it to */
  355.     RNDXR    rndx;        /* points to a symbol or opt entry */
  356.     unsigned long    offset;    /* relative offset this occured */
  357.     } OPTR, *pOPTR;
  358. #define optNil    ((pOPTR) 0)
  359. #define cbOPTR sizeof(OPTR)
  360. #define ioptNil -1
  361.  
  362. /*
  363.  * File Indirect
  364.  *
  365.  * When a symbol is referenced across files the following procedure is used:
  366.  *    1) use the file index to get the File indirect entry.
  367.  *    2) use the file indirect entry to get the File descriptor.
  368.  *    3) add the sym index to the base of that file's sym table
  369.  *
  370.  */
  371.  
  372. typedef long RFDT, *pRFDT;
  373. #define cbRFDT sizeof(RFDT)
  374. #define rfdNil    -1
  375.  
  376. /*
  377.  * The file indirect table in the mips loader is known as an array of FITs.
  378.  * This is done to keep the code in the loader readable in the area where
  379.  * these tables are merged.  Note this is only a name change.
  380.  */
  381. typedef long FIT, *pFIT;
  382. #define cbFIT    sizeof(FIT)
  383. #define ifiNil    -1
  384. #define fiNil    ((pFIT) 0)
  385.  
  386. #ifdef _LANGUAGE_PASCAL
  387. #define ifdNil -1
  388. #define ilnNil -1
  389. #define ipdNil -1
  390. #define ilineNil -1
  391. #define isymNil -1
  392. #define indexNil 16#fffff
  393. #define issNil -1
  394. #define issNull 0
  395. #define itqMax 6
  396. #define iauxNil -1
  397. #define ioptNil -1
  398. #define rfdNil -1
  399. #define ifiNil -1
  400. #endif    /* _LANGUAGE_PASCAL */
  401.  
  402.  
  403. /* Dense numbers
  404.  *
  405.  * Rather than use file index, symbol index pairs to represent symbols
  406.  *    and globals, we use dense number so that they can be easily embeded
  407.  *    in intermediate code and the programs that process them can
  408.  *    use direct access tabls instead of hash table (which would be
  409.  *    necesary otherwise because of the sparse name space caused by
  410.  *    file index, symbol index pairs. Dense number are represented
  411.  *    by RNDXRs.
  412.  */
  413.  
  414. /*
  415.  * The following table defines the meaning of each SYM field as
  416.  * a function of the "st". (scD/B == scData OR scBss)
  417.  *
  418.  * Note: the value "isymMac" is used by symbols that have the concept
  419.  * of enclosing a block of related information.     This value is the
  420.  * isym of the first symbol AFTER the end associated with the primary
  421.  * symbol. For example if a procedure was at isym==90 and had an
  422.  * isymMac==155, the associated end would be at isym==154, and the
  423.  * symbol at 155 would probably (although not necessarily) be the
  424.  * symbol for the next procedure.  This allows rapid skipping over
  425.  * internal information of various sorts. "stEnd"s ALWAYS have the
  426.  * isym of the primary symbol that started the block.
  427.  * 
  428.  
  429. ST        SC    VALUE        INDEX
  430. --------    ------    --------    ------
  431. stFile        scText    address        isymMac
  432. stLabel        scText    address        ---
  433. stGlobal    scD/B    address        iaux
  434. stStatic    scD/B    address        iaux
  435. stParam        scAbs    offset        iaux
  436. stLocal        scAbs    offset        iaux
  437. stProc        scText    address        iaux    (isymMac is first AUX)
  438. stStaticProc    scText    address        iaux    (isymMac is first AUX)
  439.  
  440. stMember    scNil    ordinal        ---    (if member of enum)
  441.     (mipsread thinks the case below has a bit, not byte, offset.)
  442. stMember    scNil    byte offset    iaux    (if member of struct/union)
  443. stMember    scBits    bit offset    iaux    (bit field spec)
  444.  
  445. stBlock        scText    address        isymMac (text block)
  446.     (the code seems to think that rather than scNil, we see scInfo for
  447.      the two cases below.)
  448. stBlock        scNil    cb        isymMac (struct/union member define)
  449. stBlock        scNil    cMembers    isymMac (enum member define)
  450.  
  451.     (New types added by SGI to simplify things:)
  452. stStruct    scInfo    cb        isymMac (struct type define)
  453. stUnion        scInfo    cb        isymMac (union  type define)
  454. stEnum        scInfo    cMembers    isymMac (enum   type define)
  455.  
  456. stEnd        scText    address        isymStart
  457. stEnd        scNil    -------        isymStart (struct/union/enum)
  458.  
  459. stTypedef    scNil    -------        iaux
  460. stRegReloc    sc???    value        old register number
  461. stForward    sc???    new address    isym to original symbol
  462.  
  463. stConstant    scInfo    value        --- (scalar)
  464. stConstant    scInfo    iss        --- (complex, e.g. string)
  465.  
  466.  *
  467.  */
  468. #endif
  469.